local vFade = CreateFrame("Frame", nil, UIParent) 

local ic=1
local ooc=0.2
local havetarget=0.4

local OnEvent = function(self, event, ...)   
	  if event == "PLAYER_ENTERING_WORLD" then BBar:ForBar("1-3","SetFrameAlpha",(ooc))
	  
		elseif (event=="PLAYER_TARGET_CHANGED") and (not UnitAffectingCombat("player")) then   
			 local a
             if(UnitExists("target")) then a=havetarget else a=ooc end BBar:ForBar("1-3","SetFrameAlpha",(a))

		elseif event=="PLAYER_REGEN_DISABLED" then BBar:ForBar("1-3","SetFrameAlpha",(ic))
		elseif event=="PLAYER_REGEN_ENABLED" then BBar:ForBar("1-3","SetFrameAlpha",(ooc))
	end 
end   
    
function vFade:new()
  self:SetScript("OnEvent", OnEvent)   
  self:RegisterEvent("PLAYER_REGEN_DISABLED")   
  self:RegisterEvent("PLAYER_REGEN_ENABLED")   
  self:RegisterEvent("PLAYER_ENTERING_WORLD")   
  self:RegisterEvent("PLAYER_TARGET_CHANGED")  
end

vFade:new()